<? require("adm_header.php"); 
writeCommonAdminTable(LA_ADMIN_NEWSL_EMAILDUMP,1);
?>

 
<form action='adm_email_dump.php' method='post'>
<p><? echo LA_ADMIN_NEWSL_EMAILDUMP_DESCR; ?></p>


<table border="0" cellpadding="5" cellspacing="0" width="100%">
  <tr>
    <td > <? echo LA_ADMIN_NEWSL_EMAILDUMP_DELIM; ?> </td>
    <td ></td>
    <td ><select size="1" name="delimiter">
        <option selected value="|">|</option>
        <option value=":">:</option>
        <option value="::">::</option>
      </select></td>
  </tr>

  <td > <? echo LA_ADMIN_NEWSL_EMAILDUMP_FIELDS; ?> </td>
    <td ></td>
    <td ><select size="1" name="fields">
        <option selected value="1"><? echo LA_ADMIN_NEWSL_EMAILDUMP_USEM ?></option>
        <option value="2"><? echo LA_ADMIN_NEWSL_EMAILDUMP_EMAIL ?></option>
        <option value="3"><? echo LA_ADMIN_NEWSL_EMAILDUMP_EMAILUSER ?></option>
      </select></td>
  </tr>

  
  <tr>
    <td ><input type="submit" value="<? echo LA_ADMIN_NEWSL_EMAILDUMP; ?>" name="submit"></td>
    <td ></td>
    <td ></td>
  </tr>
</table>


</form>

<?
if (getParam("submit",""))
{
     print " <b><a href='config/dump.txt'>".LA_ADMIN_NEWSL_EMAILDUMP_FILE."</a></b> ".LA_ADMIN_NEWSL_EMAILDUMP_FILE_MORE."<br />";
   
	$sql_email = "select distinct user_name,user_email from $usr_tbl where user_newsletter <> 1";
	$result = q ($sql_email);
	$str="";
	while ($row = mysql_fetch_array($result))
	{
		$name = $row["user_name"];
		$email = $row["user_email"];
		$count = $count +1;
		$delimiter=$_REQUEST["delimiter"];
		if (getParam("fields","")== 1)
			$str.="$name$delimiter$email\n";
		elseif (getParam("fields","")== 2)
			$str.="$email\n";
		elseif (getParam("fields","")== 3)
			$str.="$email$delimiter$name\n";
	     
	}
	
	$file_pointer = fopen($set_path . "/admin/config/dump.txt", "w+");
	fwrite($file_pointer,$str);
	fclose($file_pointer);

}
?>
<?
writeCommonAdminTable("Email Dump","");
 require("adm_footer.php"); ?>
